<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <div id="test">ttttt</div>

    <script>

        //定义Human类，同时它也构造函数 --非常通用的东西,
        //instanceof 判断上下文是来自哪个类的实例
        function Human(name,skin,number){
            if(this instanceof Human ) {
                this.username = name;
                this.skin = skin;
                this.number = number;
                this.sleep = function () {
                    console.log("会睡觉");
                };
                this.jump = function () {
                    console.log("会跳");
                }
            }else{
                return new Human(name,skin,number);
            }
        };


        var zhangfei = Human("张飞","黑色",1);
        zhangfei.sleep();









    </script>

</body>
</html>